import base64
import random
import time
import struct
import hashlib

# 插件版
# appId="com.chunmi.mijia.microwave"

class signature:
    def __init__(self):
        self.appId = "202007190935004"

    def sha1(self,src):
        return hashlib.sha1(src.encode("utf-8")).digest()

    def generateSignature(self, http_method, http_url):
        s1 = http_method + "&" + http_url + '&app_id=' + self.appId
        sha1 = signature()
        result = str(base64.urlsafe_b64encode(sha1.sha1(s1)))
        result2 = result.split("'")[1]
        result3 = result2.strip().replace("\n", "").replace("\r", "").replace('/', "")
        return result3


if __name__ == '__main__':
    sign = signature()
    print(sign.generateSignature('GET', '/activity-service/api/activity/offline/list'))